package com.woniuxy.controller;

import com.woniuxy.pojo.SysUser;
import com.woniuxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
public class LoginController {
    @Autowired
    private UserService userService;
    @RequestMapping(value = "login.html")
    public String goLogin(){
        return "login";
    }
    @RequestMapping(value = "doLogin.html")
    @ResponseBody
    public Map<String,Object> doLogin(String loginname, String password){
        Map<String,Object> map=new HashMap<>();
        SysUser user=userService.doLogin(loginname,password);
        if(user!=null){
           map.put("msg","success");
        }else{
           map.put("msg","failure");
        };
        return map;
    }
}
